

		* APPENDIX 9: Over-time Analyses with all Survey-Takers 
		
		* PART 1: survey takers from wave 1 to wavee 12
		
		
cd "$data"
use "panel.dta", clear 

* waves_taken112 // all waves takers from 1 to 12.
* waves_taken120 // all wave takers from 1 to 20


xtset id vague 


******* Labour estimates 
cd "$data/estimates"

eststo m1: xtreg leftRightW i.vague if pid6==2 & waves_taken112==12, fe
margins, at(vague=(1 2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results7, replace)

use results7.dta, clear

gen categories = 1 // labour partisans 

save results7.dta, replace 


******* Conservative estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"
xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==1 & waves_taken112==12, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results8, replace)

use results8.dta, clear

gen categories = 2 // convservative partisans 

save results8.dta, replace 


******* independent estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==0 & waves_taken112==12, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results9, replace)

use results9.dta, clear

gen categories = 3 // independent

save results9.dta, replace 

 

******* labour party's perceived position by labour partisans 
* waves 13, 14, and 19 are not available for this DV

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==2 & waves_taken112==12, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results10, replace)

use results10.dta, clear

gen categories = 4 // labour party by labour partisans 

save results10.dta, replace 

 
 
******* conservative party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV


cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrConW i.vague if pid6==1 & waves_taken112==12, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results11, replace)

use results11.dta, clear

gen categories = 5 // conservative party's perceived position by conservative partisans

save results11.dta, replace  
 
 
 
 ******* labour party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV


cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==1 & waves_taken112==12, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results12, replace)

use results12.dta, clear

gen categories = 6 // labour party's perceived position by conservative partisans

save results12.dta, replace  
  
 
 
*now append these datasets 
 
cd "$data/estimates"
use "results7.dta", clear 
append using "results8.dta"
append using "results9.dta"
append using "results10.dta"
append using "results11.dta"
append using "results12.dta"



drop _deriv _term _predict _se_margin _statistic _pvalue 

rename _margin b
rename _ci_lb b_lower 
rename _ci_ub b_upper 
rename _at vague_updated // note that wave 1, 13, 14 and 19 are not available. Margins command will jump those and will not show them, the outcome will be as if there is no gaps from 1 to the last, hence use "_at1" variable. 


rename categories category

tsset category _at1 
 
twoway (tsline b if category==3, lcolor(gs7%100) lpattern(dash)) (tsline b_lower if category==3, lcolor(gs7%100) lpattern(solid)) (tsline b_upper if category==3, lcolor(gs7%100)) (tsline b if category==1, lcolor(cranberry%100) lpattern(dash)) (tsline b_lower if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b_upper if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b if category==4, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==4, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==4, lcolor(cranberry%50) lpattern(solid)) , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) ttitle("") graphregion(margin(5 5 15 5)) title("(a) Labour identifiers") yscale(range(0(2)8)) ytick(0 2 4 6 8) ylabel(0 2 4 6 8) 
graph save "${figures}/Figure9_1a.gph",replace 


twoway (tsline b if category==2, lcolor(navy%100) lpattern(dash)) (tsline b_lower if category==2, lcolor(navy%100) lpattern(solid)) (tsline b_upper if category==2, lcolor(navy%100) lpattern(solid)) (tsline b if category==5, lcolor(navy%50) lpattern(shortdash)) (tsline b_lower if category==5, lcolor(navy%50) lpattern(solid)) (tsline b_upper if category==5 , lcolor(navy%50) lpattern(solid))  (tsline b if category==6, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==6, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==6, lcolor(cranberry%50) lpattern(solid))  , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) xtitle("") graphregion(margin(5 5 15 5)) title("(b) Conservative identifiers") ytitle("")

graph save "${figures}/Figure9_1b.gph",replace 
cd "$figures"
graph combine "Figure9_1a.gph" "Figure9_1b.gph", ycommon xsize(15) ysize(17) row(2)
graph save "${figures}/Figure9_1.gph", replace 






